package com.dc.designPattern._21_strategy.impl;

import com.dc.designPattern._21_strategy.impl.fly.FlyStragety;

/**
 * Description: 策略模式_上下文环境_鸭子
 * @author: gdc
 * @date: 2021/6/9
 * @version 1.0
 */
public abstract class Duck {

    /**
     * 飞行策略
     */
    private FlyStragety flyingStragety;

    public void setFlyingStragety(FlyStragety flyingStragety) {
        this.flyingStragety = flyingStragety;
    }


    /**
     * 叫声方法
     */
    public void speak(){
        System.out.println("呱呱呱...");
    }

    /**
     * 外形，需要在子类中进行实现
     */
    public abstract void display();

    /**
     * 飞行行为，通过策略模式实现
     */
    public void fly() {
        flyingStragety.performFly();
    }



}
